﻿using WH.Contracts.Systems.KeyValues;
using WH.Model.Systems;
using WH.Services.BaseService;
using Rw.Core.Common.Paging;

namespace WH.Services.IServices.ISystem
{
    public interface IKeyValueService : IBaseService<KeyValueEntity>
    {

        /// <summary>
        /// 创建实体
        /// </summary>
        /// <param name="entity">新的实体</param>
        /// <returns>已创建的实体</returns>
        Task<int> CreateAsync(KeyValueInputDto entity);

        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="id"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<int> UpdateAsync(string id, KeyValueInputDto input);

        /// <summary>
        /// 列表数据
        /// </summary>
        /// <param name="input">分页</param>
        /// <returns></returns>
        Task<IEnumerable<KeyValueOutputDto>> GeKeyValuesAsync(KeyValueInputDto input);

        /// <summary>
        /// 获取
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        Task<KeyValueOutputDto> GetKeyValByCodeAsync(string code);
        /// <summary>
        /// 获取
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        Task<List<KeyValueOutputDto>> GetKeyValueChildByCodeListAsync(string code);

        /// <summary>
        /// 获取树菜单
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        Task<KeyValueTreeOutputDto> FindTree(string code);

        /// <summary>
        /// 获取树菜单
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        Task<IList<KeyValueTreeOutputDto>> FindTreeByParentId(string parentId);

        /// <summary>
        /// 获取全部树菜单
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        Task<IList<KeyValueTreeOutputDto>> FindTreeAllByParentCode(string parentId);

        /// <summary>
        /// 获取全部树菜单（包含自身）
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        Task<IList<KeyValueTreeOutputDto>> FindTreeAllAndSelfByParentCode(string code);

        /// <summary>
        /// 获取树菜单值
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        Task<IPagedList<KeyValueTreeOutputDto>> GetTreeValues(string parentId, Pager pager);

        /// <summary>
        /// 获取字典值（带缓存）
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        Task<KeyValueOutputDto?> GetKeyValueByCodeAsync(string code);

        /// <summary>
        /// 获取所有子集id
        /// </summary>
        /// <param name="parentId"></param>
        /// <returns></returns>
        Task<string[]> GetChildIds(string parentId);
    }
}
